Skip to content

[Bugfix #548] Fix analytics median, workspace scoping, remove activeBuilders#549

Merged
waleedkadous merged 5 commits intomainfrom
builder/bugfix-548-analytics-median-for-bug-close
Feb 24, 2026
Merged

[Bugfix #548] Fix analytics median, workspace scoping, remove activeBuilders#549
waleedkadous merged 5 commits intomainfrom
builder/bugfix-548-analytics-median-for-bug-close

Conversation

@waleedkadous
Copy link
Contributor

Summary

Four analytics fixes: switch time-to-merge and bug close time from average to median (outliers were skewing the average to 47h), fix consultation workspace scoping to use prefix match so builder worktree paths count, and remove the unused activeBuilders metric.

Fixes #548

Root Cause

  1. computeAvgHours() used arithmetic mean — a few long-open bugs/PRs disproportionately skewed the result
  2. Consultation workspace filtering used exact workspace_path = ? match — builder worktree paths like .builders/bugfix-535-... didn't match the parent workspace
  3. activeBuilders count was not useful information in the analytics dashboard

Fix

  1. Replaced computeAvgHours with computeMedianHours (sorts durations, picks middle value)
  2. Renamed avgTimeToMergeHoursmedianTimeToMergeHours and avgTimeToCloseBugsHoursmedianTimeToCloseBugsHours across API, types, and dashboard
  3. Changed workspace filter from exact match to (workspace_path = ? OR workspace_path LIKE ?/%) prefix match with trailing-slash normalization
  4. Removed activeBuilders from AnalyticsResponse, computeAnalytics signature, tower routes, and dashboard component

Test Plan

  • Regression test: median with outliers (odd count: [2,3,100] → 3)
  • Regression test: median with outliers (even count: [1,2,10,20] → 6)
  • Regression test: bug close time uses median
  • Regression test: activeBuilders not in response
  • Regression test: workspace prefix matches builder worktree paths
  • Regression test: prefix doesn't match unrelated paths (e.g., /codev vs /codev-other)
  • Regression test: trailing-slash workspace filter works
  • Build passes
  • All 2024 tests pass (0 failures)

CMAP Review

To be added after review

…atching, remove activeBuilders

- Replace computeAvgHours with computeMedianHours for time-to-merge and
  bug close time (outliers no longer skew the result)
- Rename avgTimeToMergeHours → medianTimeToMergeHours and
  avgTimeToCloseBugsHours → medianTimeToCloseBugsHours
- Fix consultation workspace scoping: use prefix match (LIKE) instead of
  exact match so builder worktree paths (.builders/*) count toward the
  parent workspace's consultations
- Remove activeBuilders from analytics response and dashboard
- Update dashboard test fixtures to use new property names
  (medianTimeToMergeHours, medianTimeToCloseBugsHours, no activeBuilders)
- Fix stale doc comment in analytics.ts (removed builder count reference)
- Fix stale test description string referencing avgTimeToCloseBugsHours
- Fix inaccurate comment in metrics.ts about repo renames
@waleedkadous
Copy link
Contributor Author

Architect Integration Review

Verdict: APPROVE

All four fixes are clean and correct. Median implementation handles odd/even cases properly. Workspace prefix matching uses exact + LIKE with trailing slash normalization to avoid false positives (e.g. codev-other won't match codev). activeBuilders fully removed. Marketing files in diff are merge-base artifacts, not in the branch commits.


Architect integration review

@waleedkadous waleedkadous merged commit 5e7f521 into main Feb 24, 2026
6 checks passed
@waleedkadous waleedkadous deleted the builder/bugfix-548-analytics-median-for-bug-close branch February 24, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Analytics: median for bug close time, fix consultation scoping, remove activeBuilders

1 participant